package errmsg

const (
	SUCCESS = 200
	ERROR   = 500

	// code = 1000 用户模块的错误
	ERROR_USERNAME_USED    = 1001
	ERROR_PASSWORD_WRONG   = 1002
	ERROR_USER_NOT_EXIST   = 1003
	ERROR_USER_DATA_FAIL   = 1004
	ERROR_USER_NO_RIGHT    = 1005
	ERROR_TOKEN_NOT_EXIST  = 1006
	ERROR_TOKEN_RUNTIME    = 1007
	ERROR_TOKEN_WRONG      = 1008
	ERROR_TOKEN_TYPE_WRONG = 1009

	// code 2000 商品模块的错误
	ERROR_GOODS_NOT_EXIST = 2001
	// code 3000 分类模块的错误
	ERROR_CATEGORY_USED      = 3001
	ERROR_CATEGORY_NOT_EXIST = 3002
	ERROR_CATEGORY_DATA_FAIL = 3003
	// 订单模块的错误
	ERROR_ORDERS_NOT_EXIST = 4001

	// 轮播图模块的错误
	ERROR_CAROUSEL_NOT_EXIST = 5001

	// 订单模块的错误
	ERROR_CARTS_NOT_EXIST = 6001
)

var codeMsg = map[int]string{
	SUCCESS: "OK",
	ERROR:   "FAIL",

	ERROR_USERNAME_USED:      "用户名已存在",
	ERROR_PASSWORD_WRONG:     "用户密码错误",
	ERROR_USER_NOT_EXIST:     "用户不存在",
	ERROR_USER_NO_RIGHT:      "用户无权限",
	ERROR_TOKEN_NOT_EXIST:    "Token不存在",
	ERROR_TOKEN_RUNTIME:      "Token已过期",
	ERROR_TOKEN_WRONG:        "Token错误",
	ERROR_TOKEN_TYPE_WRONG:   "Token格式错误",
	ERROR_USER_DATA_FAIL:     "数据格式未通过",
	ERROR_CATEGORY_USED:      "分类名已存在",
	ERROR_CATEGORY_NOT_EXIST: "分类名不存在",
	ERROR_CATEGORY_DATA_FAIL: "分类名格式不正确",
	ERROR_GOODS_NOT_EXIST:    "商品不存在",
	ERROR_ORDERS_NOT_EXIST:   "订单不存在",
	ERROR_CAROUSEL_NOT_EXIST: "轮播图不存在",
	ERROR_CARTS_NOT_EXIST:    "订单不存在",
}

func GetErrMsg(code int) string {
	return codeMsg[code]
}
